<?php
function fillArray($arr1,$arr2,$count){
	for($i=0; $i<sizeof($arr2); $i++){
		if($arr1[$i] != 'except'){
			$arr2[$i] = $count;
		}	
	}
	return $arr2;
}

function checkRepetition($arg,$c_buf){
	for($i=0; $i<sizeof($c_buf); $i++){
		if($arg == $c_buf[$i]){
			return true;
		}
	}
	return false;
}

function removeID($array_id,$select){
	$temp = array();
	$z = 0;
	$x = 0;
	while($x < sizeof($array_id)){
		if($x == $select){$x++;}
		$temp[$z] = $array_id[$x];
		$x++;$z++;
	}
	return $temp;
}

function quesToArray($res){
	$a_result = array();
	while($row = mysql_fetch_array($res)){
		$a_temp = array();
		$a_temp[0] = $row["c_id"];
		$a_temp[1] = $row["q_id"];
		$a_temp[2] = $row["c_title"];
		$a_temp[3] = $row["c_order"];
		$a_result[] = $a_temp;
	}
	return $a_result;
}

function titlesToArray($res){
	$arr1 = array();
	while($row = mysql_fetch_array($res)){
		$arr2 = array();
		$arr2[0] = $row["q_id"];
		$arr2[1] = $row["q_title"];
		$arr1[] = $arr2;
	}
	return $arr1;
}

function getIds($complexity){
	$arr = array();
	$main_res = mysql_query("select * from questions where cat_id ='".$_SESSION['category_id']."' and q_complexity = ".$complexity." order by q_id desc");
	while($main = mysql_fetch_array($main_res)){
		$arr[] = $main["q_id"];
	}
	return $arr;
}

function getFullQuestion($id,$count,$arr1,$arr2){
	$c = array();
	$title_q;
	for($i=0; $i<sizeof($arr1); $i++){
		if($arr1[$i][1] == $id){
			$c[] = new Choice($arr1[$i][2],$arr1[$i][1], $arr1[$i][3]);
		}
	}
	for($j=0; $j<sizeof($arr2); $j++){
		if($arr2[$j][0] == $id){
			$title_q = $arr2[$j][1];
			break;
		}
	}
	return array($count, $title_q, $c);
}
?>
